import bus from "@/bus";
import { renderButton, formatDate } from '@/util'
import { Poptip, Icon } from 'view-design';

let prevQuarter = () => { // 计算上一个季度
  let date = new Date()
  let curMonth = date.getMonth() + 1
  let curQuarter = Math.floor((curMonth % 3 == 0 ? (curMonth / 3) : (curMonth / 3 + 1))) // 当前季度
  let prQuarter = curQuarter == 1 ? 4: curQuarter-1 // 上一个季度
  let year = curQuarter == 1 ? (date.getFullYear() - 1) : (date.getFullYear())
  return {
    year: year + '',
    quarter: prQuarter + ''
  }
}
let data = {
  status: 'pass',
  totalItem: 1,
  pageSize: window.$pageSize,
  currentPage: 1,
  form: {
    time: prevQuarter().year,
    year: '',
    addressArr: [],
    areaId: null,
    cityId: null,
    provinceId: null,
    quarter: prevQuarter().quarter,
    distributorId: null,
    distributorName: '',
    storeTypeId: null,
    storeId: null,
    storeName: '',
    status: '0'
  },
  columns: [ {
    title: '门店名称',
    key: 'storeName',
    align: 'left',
    minWidth: 200,
    tooltip: true
  }, {
    title: '经销商',
    key: 'distributorName',
    align: 'left',
    minWidth: 200,
    tooltip: true
  }, {
    title: '门店类型',
    key: 'storeTypeName',
    align: 'left',
    minWidth: 120
  }, {
    title: '门头编号',
    key: 'storeNo',
    align: 'left',
    minWidth: 200
  }, {
    title: '季进货指标',
    key: 'quarterPurchase',
    align: 'right',
    minWidth: 120
  }, {
    title: '季有效进货量',
    key: 'quarterTaskQuantity',
    align: 'right',
    minWidth: 120
  }, {
    title: '补发积分',
    key: 'quarterRepairIntegral',
    align: 'right',
    minWidth: 130,
    renderHeader: (h, params) => {
      return <Poptip trigger="hover" transfer width="200" word-wrap content="季度任务完成后补发的进货积分">
                  <span>补发积分</span>
                  <Icon type="ios-help-circle" />
              </Poptip>
      }
  }, {
    title: '补发返利',
    key: 'quarterRepairRebate',
    align: 'right',
    minWidth: 130,
    renderHeader: (h, params) => {
      return <Poptip trigger="hover" transfer width="200" word-wrap content="季度任务完成后补发的进货返利">
                  <span>补发返利</span>
                  <Icon type="ios-help-circle" />
              </Poptip>
      }
  }, {
    key: 'quarterRewardIntegral',
    align: 'right',
    minWidth: 130,
    renderHeader: (h, params) => {
      return <Poptip trigger="hover" transfer width="200" word-wrap content="隔月退货没完成任务，季度补差发现多扣或者多给的情况还回去">
                  <span>积分补差</span>
                  <Icon type="ios-help-circle" />
              </Poptip>
      }
  }, {
    key: 'quarterRewardRebate',
    align: 'right',
    minWidth: 130,
    renderHeader: (h, params) => {
      return <Poptip trigger="hover" transfer width="200" word-wrap content="隔月退货没完成任务，季度补差发现多扣或者多给的情况还回去">
                  <span>返利补差</span>
                  <Icon type="ios-help-circle" />
              </Poptip>
      }
  }, {
    title: '审核状态',
    key: 'statusMeaning',
    align: 'left',
    minWidth: 120
  }, {
    title: '操作',
    align: 'right',
    fixed: 'right',
    minWidth: 150,
    render: (h, params) => {
      return (
          <div>
            {renderButton(h, {text: '审核', type: 'primary', disabled: params.row.status !== 0}, () => {bus.$emit("checkRow", {row: params.row})})}
            {renderButton(h, {text: '查看', disabled: params.row.status === 0}, () => {bus.$emit("detailRow", {row: params.row})})}
          </div>
        )
    }
  }],
  data: []
}
export default data;
